package com.czp.user.mapper.impl;

import java.util.List;

import org.apache.ibatis.session.RowBounds;

import com.czp.framework.mapper.BaseMapperSupport;
import com.czp.log.model.Log;
import com.czp.menu.model.Menu;
import com.czp.user.mapper.IUserMapper;
import com.czp.user.model.RelationRole;
import com.czp.user.model.User;


/**
 * 【环 境】：J2SE 1.7
 * @author   柴志鹏	CHAIZP@GMAIL.COM
 * @version  version 1.0
 * @since    2014-4-25
 */
public class UserMapperImpl extends BaseMapperSupport implements IUserMapper {
	
	public int addUser(User user) throws Exception {
		return this.getSqlSession().insert(
				"com.czp.user.mapper.IUserMapper.addUser", user);
	}
	
	public int editorUser(User user) throws Exception {
		return this.getSqlSession().insert(
				"com.czp.user.mapper.IUserMapper.editorUser", user);
	}
	
	public int deleteUser(User user) throws Exception {
		return this.getSqlSession().insert(
				"com.czp.user.mapper.IUserMapper.deleteUser", user);
	}
	
	public User getUserInfoByPid(String personId) throws Exception {
		return this.getSqlSession().selectOne(
				"com.czp.user.mapper.IUserMapper.getUserInfoByPid", personId);
	}
	
	public List<RelationRole> queryRelationRole(String personId) throws Exception {
		return this.getSqlSession().selectList(
				"com.czp.user.mapper.IUserMapper.queryRelationRole", personId);
	}
	
	public List<RelationRole> getSelectedRoleList(RelationRole relRole, RowBounds bounds) throws Exception {
		return this.getSqlSession().selectList(
				"com.czp.user.mapper.IUserMapper.getSelectedRoleList", relRole, bounds);
	}
	
	public int getSelectedRoleRecords(RelationRole relRole) throws Exception {
		return this.getSqlSession().selectOne(
				"com.czp.user.mapper.IUserMapper.getSelectedRoleRecords", relRole);
	}
	
	public int insertRelationRole(RelationRole relRole) throws Exception {
		return this.getSqlSession().insert(
				"com.czp.user.mapper.IUserMapper.insertRelationRole", relRole);
	}
	
	public int deleteRelationRole(RelationRole relRole) throws Exception {
		return this.getSqlSession().delete(
				"com.czp.user.mapper.IUserMapper.deleteRelationRole", relRole);
	}
	
	public int matchAddRelationRole(RelationRole relRole) throws Exception {
		return this.getSqlSession().selectOne(
				"com.czp.user.mapper.IUserMapper.matchAddRelationRole", relRole);
	}
	
	public List<Menu> queryRelationMenu(String personId) throws Exception {
		return this.getSqlSession().selectList(
				"com.czp.user.mapper.IUserMapper.queryRelationMenu", personId);
	}
	
	public User login(String username) throws Exception {
		return this.getSqlSession().selectOne(
				"com.czp.user.mapper.IUserMapper.login", username);
	}
	
	public int isUserExist(String username) throws Exception {
		return this.getSqlSession().selectOne(
				"com.czp.user.mapper.IUserMapper.isUserExist", username);
	}

	public String queryPasswordById(int userId) throws Exception {
		return this.getSqlSession().selectOne(
				"com.czp.user.mapper.IUserMapper.queryPasswordById", userId);
	}
	
	public int modifyPassword(User user) throws Exception {
		return this.getSqlSession().update(
				"com.czp.user.mapper.IUserMapper.modifyPassword", user);
	}
	
	public int addLoginLogInfo(Log log) throws Exception {
		return this.getSqlSession().insert(
				"com.czp.user.mapper.IUserMapper.addLoginLogInfo", log);
	}
	
}
